package com.xjh.utils.enumutils;

import java.util.Objects;

/**
 * @author XuJianHua
 * @date 2022-09-06 16:00:04
 * @description
 */
public class TestEnum {
    public static void main(String[] args) {
        // 根据某个信息：type / name / description 匹配到特定的某个枚举
        // 根据type 匹配到该条枚举信息
        PaymentApplicationColumnEnum paymentApplicationColumnEnum = PaymentApplicationColumnEnum.getEnumByType(1);
        System.out.println(paymentApplicationColumnEnum);//ENTRY_DEPARTMENT
        System.out.println(paymentApplicationColumnEnum.getDescription());//入账部门
        System.out.println(paymentApplicationColumnEnum.getControlName());//entryDepartment
        System.out.println(paymentApplicationColumnEnum.getType());//1

        PaymentApplicationColumnEnum paymentApplicationColumnEnum1 = PaymentApplicationColumnEnum.getEnumByDescription("入账部门");
        System.out.println(paymentApplicationColumnEnum1.getDescription());//入账部门
        System.out.println(paymentApplicationColumnEnum1.getControlName());//entryDepartment
        System.out.println(paymentApplicationColumnEnum1.getType());//1

        Integer Type = Objects.requireNonNull(PaymentApplicationColumnEnum.getEnumByDescription("入账部门")).getType();

//     枚举   用在switch上

        switch (Objects.requireNonNull(PaymentApplicationColumnEnum.getEnumByType(Type))){
            case ENTRY_DEPARTMENT:
                System.out.println("这是入账部门");
                break;
            case PAYEE:
                System.out.println("这是申请人");
                break;
            default:
                System.out.println("抛异常算了");
        }


    }
}
